<template>
  <div>
    <el-col>
      <el-menu router>
        <el-menu-item index="classManager">
          <span class="sp2">
            <el-icon><VideoPlay /></el-icon>
          </span>
          <span>课程管理</span>
        </el-menu-item>
      </el-menu>
    </el-col>
    <!-- 搜索框 -->
    <search-bar />
    <!-- 选项卡 -->
    <div class="tab-titles">
      <div
        class="box1"
        v-for="(title, index) in titles"
        :key="index"
        :class="{ active: selectedIndex === index }"
        @click="selectTab(index)"
      >
        {{ title }}
      </div>
    </div>
    <!-- 选项卡分支 -->
    <div class="tab-content">
      <!-- 课程列表 -->
      <div v-if="selectedIndex === 0">
        <el-table :data="tableData1" style="width: 100%" stripe>
          <el-table-column prop="post" label="海报" width="180">
            <template #default="{ row }">
              <div>
                <img :src="row.post" width="50" alt="" />
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="name" label="课程" width="180" />
          <el-table-column prop="date" label="上传时间" />
          <el-table-column prop="type" label="类型" width="180" />
          <el-table-column prop="lookNumber" label="浏览量" width="180" />
          <el-table-column prop="major" label="专业" />
          <el-table-column prop="operation" label="操作" width="180">
            <p class="p1">
              <span @click="clickMe">下架</span>
              <span>编辑</span>
              <span>删除</span>
            </p>
          </el-table-column>
        </el-table>
      </div>
      <!-- 待审核课程 -->
      <div v-if="selectedIndex === 1">
        <el-table :data="tableData2" style="width: 100%">
          <el-table-column prop="post" label="海报" width="180">
            <template #default="{ row }">
              <div>
                <img :src="row.post" width="50" alt="" />
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="name" label="课程" width="180" />
          <el-table-column prop="date" label="上传时间" />
          <el-table-column prop="type" label="类型" width="180" />
          <el-table-column prop="state" label="审核状态" width="180">
            <el-button type="info" round>未审核</el-button>
          </el-table-column>
          <el-table-column prop="operation" label="操作">
            <span class="sp1">
              <el-icon><Document /></el-icon>
              审核课程
            </span>
          </el-table-column>
        </el-table>
      </div>
      <!-- 待审核视频 -->
      <div v-if="selectedIndex === 2">
        <el-table :data="tableData3" style="width: 100%">
          <el-table-column prop="post" label="海报" width="180">
            <template #default="{ row }">
              <div>
                <img :src="row.post" width="50" alt="" />
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="date" label="上传时间" width="180" />
          <el-table-column prop="state" label="审核状态">
            <el-button type="info" round>未审核</el-button>
          </el-table-column>
          <el-table-column prop="operation" label="操作">
            <p class="p2">
              <span>
                <el-icon><VideoPlay /></el-icon>
                预览视频
              </span>
              <span>
                <el-icon><Download /></el-icon>
                下载视频
              </span>
              <span>
                <el-icon><Refresh /></el-icon>
                替换视频
              </span>
              <span>
                <el-icon><Document /></el-icon>
                审核视频
              </span>
            </p>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
import SearchBar from '../../components/SearchBar.vue'
import { classList, classIng, classEd } from '../../api/class'
export default {
  name: 'ClassManager',
  data () {
    return {
      titles: ['课程列表', '待审核课程', '待审核视频'],
      selectedIndex: 0,
      tableData1: [],
      tableData2: [],
      tableData3: []
    }
  },
  methods: {
    selectTab (index) {
      this.selectedIndex = index
    },
    // 课程列表实现
    classL () {
      classList().then((res) => {
        if (res.data.code === 200) {
          console.log(res)
          this.tableData1 = res.data.data
        }
      })
    },
    // 待审核课程
    classI () {
      classIng().then((res) => {
        if (res.data.code === 200) {
          console.log(res)
          this.tableData2 = res.data.data
        }
      })
    },
    // 待审核视频
    classE () {
      classEd().then((res) => {
        if (res.data.code === 200) {
          console.log(res)
          this.tableData3 = res.data.data
        }
      })
    }
  },
  created () {
    this.classL()
    this.classI()
    this.classE()
  },
  components: {
    SearchBar
  }
}
</script>

<style lang="scss" scoped>
.tab-titles {
  display: flex;
  .box1 {
    width: 100px;
    height: 45px;
    line-height: 36px;
    text-align: center;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
    font-weight: 900;
  }
}
.active {
  background-color: #fff;
  color: #0f85c9;
}
.p1 {
  display: flex;
  span {
    color: #0f85c9;
    padding-right: 20px;
  }
}
.el-col {
  margin-bottom: 25px;
}
.p2 {
  display: flex;
  span {
    margin-right: 20px;
    display: block;
    width: 80px;
    color: #0f85c9;
  }
}
.sp1{
  color: #0f85c9;
}
.sp2{
  color: #ffd04b;
}
</style>
